< previous page page_346 next page >

Page 346
txtResultA text box used to hold the result of the calculation.
open.gifcmdExecuteA command button used to perform the calculation. The users can change the button's caption through the ButtonCaption property of the control.
After you finish placing the controls, your control should look similar to the one shown in Figure 15.4.
Creating the Interface
The next step in creating the Calculator control is to write code for the properties. As you may recall from the preceding chapter, the ActiveX Control Interface Wizard enables you to expose properties, methods, and events of your control. The sample Calculator control includes a number of properties that can be exposed through the wizard. Follow these steps:
sarrow.gifSee ''Using the ActiveX Control Interface Wizard," p. 323
1. Start the Wizard by choosing the ActiveX Control Interface Wizard item from the Add-Ins menu. Then click Next.
2. In the Select Interface Members dialog box, add Caption property to the control.
3. In the Create Custom Interface Members dialog box, add two new properties, a method, and an event, as shown in Figure 15.5. These custom members are as follows:
d6ef40187df115e88326dbc94f09ab9a.gif
Operation propertyDetermines whether the control adds, subtracts, multiplies, or divides
d6ef40187df115e88326dbc94f09ab9a.gif
ButtonCaption propertyDetermines the caption of the command button
d6ef40187df115e88326dbc94f09ab9a.gif
ValidateEntries methodValidates user input into the text boxes
d6ef40187df115e88326dbc94f09ab9a.gif
BadEntries eventFires when erroneous input is encountered
0346-01.jpg
Figure 15.5
The Calculator control needs four new control members.
4. In the Set Mapping dialog box, map the ButtonCaption property to the Caption property of cmdExecute. Also, map the Caption property of the control to the Caption property of lblCaption.

 
< previous page page_346 next page >